package com.summer.framework.stream.sender;

import com.summer.framework.api.dto.Msg;
import com.summer.framework.stream.mq.StreamClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @auther: 杨杰
 * @date: 2019/5/10 10:09
 * @description:
 */
@Service
@Slf4j
public class UserSender implements UserSenderService {

    @Resource
    private StreamClient streamClient;

    @Override
    public boolean send(Msg msg) {

        log.info("UserSender发送消息,message:" + msg.toString());
        return streamClient.output()
                .send(MessageBuilder.withPayload(msg)
                        //.setHeader("version","1.0.0")
                        .setHeader("x-delay", "5000")
                        .build());
    }

}
